home *** CD-ROM | disk | FTP | other *** search
/ Mastering Microsoft Visual Basic 5 / Mastering Microsoft Visual Basic 5.ISO / sampapps / cancelasynch / frmclient.frm < prev    next >
Text File  |  1996-11-07  |  4KB  |  138 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.1#0"; "COMCTL32.OCX"
  3. Begin VB.Form frmClient 
  4.    BackColor       =   &H80000000&
  5.    Caption         =   "Client"
  6.    ClientHeight    =   3195
  7.    ClientLeft      =   60
  8.    ClientTop       =   345
  9.    ClientWidth     =   4680
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3195
  12.    ScaleWidth      =   4680
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin ComctlLib.ProgressBar pbClient 
  15.       Height          =   645
  16.       Left            =   180
  17.       TabIndex        =   0
  18.       Top             =   2100
  19.       Visible         =   0   'False
  20.       Width           =   1725
  21.       _ExtentX        =   3043
  22.       _ExtentY        =   1138
  23.       BorderStyle     =   1
  24.       MouseIcon       =   "frmClient.frx":0000
  25.    End
  26.    Begin VB.CommandButton cmdStart 
  27.       Caption         =   "&Start"
  28.       Default         =   -1  'True
  29.       Height          =   525
  30.       Left            =   1710
  31.       TabIndex        =   2
  32.       Top             =   1320
  33.       Width           =   1245
  34.    End
  35.    Begin ComctlLib.StatusBar sbClient 
  36.       Align           =   2  'Align Bottom
  37.       Height          =   435
  38.       Left            =   0
  39.       TabIndex        =   1
  40.       Top             =   2760
  41.       Width           =   4680
  42.       _ExtentX        =   8255
  43.       _ExtentY        =   767
  44.       SimpleText      =   ""
  45.       BeginProperty Panels {2C787A51-E01C-11CF-8E74-00A0C90F26F8} 
  46.          NumPanels       =   2
  47.          BeginProperty Panel1 {2C787A53-E01C-11CF-8E74-00A0C90F26F8} 
  48.             Object.Width           =   2540
  49.             MinWidth        =   2540
  50.             TextSave        =   ""
  51.             Key             =   ""
  52.             Object.Tag             =   ""
  53.          EndProperty
  54.          BeginProperty Panel2 {2C787A53-E01C-11CF-8E74-00A0C90F26F8} 
  55.             AutoSize        =   1
  56.             Bevel           =   0
  57.             Object.Width           =   5265
  58.             MinWidth        =   2540
  59.             TextSave        =   ""
  60.             Key             =   ""
  61.             Object.Tag             =   ""
  62.          EndProperty
  63.       EndProperty
  64.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  65.          Name            =   "MS Sans Serif"
  66.          Size            =   8.25
  67.          Charset         =   0
  68.          Weight          =   400
  69.          Underline       =   0   'False
  70.          Italic          =   0   'False
  71.          Strikethrough   =   0   'False
  72.       EndProperty
  73.       MouseIcon       =   "frmClient.frx":001C
  74.    End
  75. End
  76. Attribute VB_Name = "frmClient"
  77. Attribute VB_GlobalNameSpace = False
  78. Attribute VB_Creatable = False
  79. Attribute VB_PredeclaredId = True
  80. Attribute VB_Exposed = False
  81. Option Explicit
  82. Private WithEvents obj As clsAsynch
  83. Attribute obj.VB_VarHelpID = -1
  84.  
  85. Private Sub cmdStart_Click()
  86.   Me.Enabled = False
  87.   sbClient.Panels(1).Text = "Working..."
  88.   frmCancel.Show
  89.   pbClient.Visible = True
  90.   obj.SomeAsynchronousTask
  91. End Sub
  92.  
  93. Private Sub Form_Load()
  94.   ' Set the parent of the progress bar to be
  95.   ' the status bar
  96.   SetParent pbClient.hWnd, sbClient.hWnd
  97.   pbClient.Min = 0
  98.   pbClient.Max = 100
  99.   pbClient.Value = 0
  100.   
  101.   Set obj = New clsAsynch
  102. End Sub
  103.  
  104. Private Sub Form_Resize()
  105.   ' Move the progress bar to fit the pane of the client
  106.   With sbClient
  107.     pbClient.Move .Panels(2).Left, 10, .Panels(2).Width, .Height - 20
  108.   End With
  109. End Sub
  110.  
  111. Sub obj_IAmWorkingOnIt(ByVal pc As Long, ByRef bCancel As Boolean)
  112.   If pc / 3 = Int(pc / 3) Then
  113.     sbClient.Panels(1).Text = ""
  114.   Else
  115.     sbClient.Panels(1).Text = "Working..."
  116.   End If
  117.   pbClient.Value = pc
  118.   bCancel = frmCancel.bCancel
  119. End Sub
  120.  
  121. Sub obj_TaskComplete()
  122.   Unload frmCancel
  123.   Me.Enabled = True
  124.   sbClient.Panels(1).Text = ""
  125.   pbClient.Value = 0
  126.   pbClient.Visible = False
  127.   MsgBox "Asynchronous task is completed."
  128. End Sub
  129.  
  130. Sub obj_Taskcancelled()
  131.   Unload frmCancel
  132.   Me.Enabled = True
  133.   sbClient.Panels(1).Text = ""
  134.   pbClient.Value = 0
  135.   pbClient.Visible = False
  136.   MsgBox "Asynchronous task is cancelled."
  137. End Sub
  138.